home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Telephone Manager / Stiletto Sources / ModuleSources / EnglishToIntl.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-26  |  3.3 KB  |  127 lines  |  [TEXT/MPS ]

  1. /************************************************************************************************/
  2. /*                                                                                                */
  3. /*    Module Name:    EnglishToIntl                                                                */
  4. /*                                                                                                */
  5. /*    File Name:        EnglishToIntl.c                                                                */
  6. /*                                                                                                */
  7. /*    © Apple Computer, Inc. 1991-1995                                                            */
  8. /*    All Rights Reserved                                                                            */
  9. /*                                                                                                */
  10. /*    Revision History:                                                                            */
  11. /*                                                                                                */
  12. /*        Date        Who                    Modification                                            */
  13. /*                                                                                                */
  14. /*        1991-08-12    Chris Halim            Original version                                        */
  15. /*        1995-06-26    Jaakko Railo        Version 2.0                                                */
  16. /*                                                                                                */
  17. /************************************************************************************************/
  18.  
  19. /****************************************** DESCRIPTION ******************************************
  20.  
  21. *************************************************************************************************/
  22.  
  23. /******************************************** HEADERS *******************************************/
  24.  
  25. #include "string.h"
  26. #include "TextUtils.h"
  27.  
  28. #include "TestModule.h"
  29.  
  30. /****************************************** DEFINITIONS *****************************************/
  31.  
  32. #define    rConfigDLOG            10000
  33. #define    kConfig                3
  34. #define    kLanguage            4
  35.  
  36. /****************************************** PROTOTYPES ******************************************/
  37.  
  38. short    GetConfigString (Str255 config, short *lang);
  39. void     DoTest (CHRSPtr paramPtr);
  40.  
  41. /************************************************************************************************/
  42. /************************************************************************************************/
  43.  
  44.  
  45. pascal short TestModule (CHRSPtr paramPtr)
  46. {
  47.     short    returnValue = noErr;
  48.     
  49.     if (paramPtr->version <= kTestModuleVersion) {
  50.         
  51.         DoTest (paramPtr);
  52.         
  53.     }
  54.     else
  55.         returnValue = kWrongVersion;
  56.         
  57.     return (returnValue);
  58. }
  59.  
  60.  
  61. short    GetConfigString (Str255 config, short *lang)
  62. {
  63.     short        itemKind;
  64.     Handle        itemHand;
  65.     Rect        itemRect;
  66.     short        itemHit;
  67.     DialogPtr    theDialog;
  68.     Str255        tStr;
  69.     long        tLong;
  70.     
  71.     if ((theDialog = GetNewDialog (rConfigDLOG, nil, (WindowPtr)(-1L))) != nil) {
  72.  
  73.         GetDItem (theDialog, kConfig, &itemKind, &itemHand, &itemRect);
  74.         setitext (itemHand, config);
  75.  
  76.         ShowWindow (theDialog);
  77.         
  78.         ModalDialog (nil, &itemHit);
  79.         
  80.         if (itemHit == ok) {
  81.             GetDItem (theDialog, kConfig, &itemKind, &itemHand, &itemRect);
  82.             getitext (itemHand, config);
  83.  
  84.             GetDItem (theDialog, kLanguage, &itemKind, &itemHand, &itemRect);
  85.             GetIText (itemHand, tStr);
  86.             StringToNum (tStr, &tLong);
  87.             *lang = tLong;
  88.         }
  89.         
  90.         DisposeDialog (theDialog);
  91.     }
  92.     else
  93.         itemHit = -1;
  94.     
  95.     return (itemHit);
  96. }
  97.  
  98.  
  99. void DoTest (CHRSPtr paramPtr)
  100. {
  101.     TELHandle    termHand = GetCurrentTELHandle (paramPtr);
  102.     OSErr        errCode;
  103.     Str255        inputPtr;        // we are assuming config string won't be > 256 chars
  104.     Ptr            outputPtr, tPtr;
  105.     short        lang, itemHit;
  106.     
  107.     tPtr = TELGetConfig (termHand);
  108.     if (tPtr) {
  109.         strcpy (inputPtr, tPtr);
  110.         DisposPtr (tPtr);
  111.     }
  112.     
  113.     if ((itemHit = GetConfigString (inputPtr, &lang)) == ok) {
  114.     
  115.         if ((errCode = TELEnglishToIntl (termHand, inputPtr, &outputPtr, lang)) == noErr) {
  116.             Print (paramPtr, " EnglishToIntl --> %s", outputPtr);
  117.             
  118.             if (outputPtr)
  119.                 DisposPtr (outputPtr);
  120.         }
  121.         else
  122.             Print (paramPtr, "### TELEnglishToIntl fails : %d", errCode);
  123.     }
  124. }
  125.  
  126.  
  127.